package xhwl.hmo.mall.ui;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.View;
import android.widget.TextView;

import xhwl.hmo.mall.BaseActivity;
import xhwl.hmo.mall.R;

/**
 * Created by admin on 2017-10-31.
 */

public class PaymentFailActivity extends BaseActivity implements View.OnClickListener {
    private android.widget.TextView tvDesc;
    private android.widget.TextView tvPay;
    private android.widget.TextView tvCheckOrder;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_payment_fail);

    }

    @Override
    public void initViews() {
        initTitleViews();
        this.tvCheckOrder = (TextView) findViewById(R.id.tvCheckOrder);
        this.tvPay = (TextView) findViewById(R.id.tvPay);
        this.tvDesc = (TextView) findViewById(R.id.tvDesc);
        initRuleText();
    }
    private void initRuleText() {
        SpannableString jkcn = new SpannableString("24小时");
        jkcn.setSpan(new ClickableSpan() {
            /**
             * @param ds
             */
            @Override
            public void updateDrawState(TextPaint ds) {
                // TODO Auto-generated method stub
                super.updateDrawState(ds);
                ds.setColor(Color.parseColor("#e82331"));
                ds.setUnderlineText(false);
            }

            @Override
            public void onClick(View widget) {
                // TODO Auto-generated method stub
            }
        }, 0, jkcn.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        tvDesc.setHighlightColor(Color.TRANSPARENT);
        tvDesc.append("支付失败\n");
        tvDesc.append("请在");
        tvDesc.append(jkcn);
        tvDesc.append("内完成付款\n");
        tvDesc.append("否则订单会被系统取消");
        // tvRule.append(jkcn);
        tvDesc.setMovementMethod(LinkMovementMethod.getInstance());
    }

    @Override
    protected void setUpTitleView() {
        super.setUpTitleView();
        titleTextView.setText("支付失败");
    }

    @Override
    public void initListener() {
        this.tvCheckOrder.setOnClickListener(this);
        this.tvPay.setOnClickListener(this);
    }

    @Override
    public void loadData() {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.tvCheckOrder:
//                Intent intent=new Intent(mContext,InfoOrderActivity.class);
//                intent.putExtra("order_id",getIntent().getStringExtra(PaymentActivity.EXTRA_ORDER_NO));
//                startActivity(intent);
                Intent intent=new Intent(mContext,MyOrderListActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                break;
            case R.id.tvPay:
                finish();
                break;
        }
    }
}
